home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!austern
- From: kuehl@uzwil.informatik.uni-konstanz.de (Dietmar Kuehl)
- Newsgroups: comp.std.c++
- Subject: Why is there no 'queue::top()'?
- Date: 26 Jan 1996 09:33:23 PST
- Organization: Fakultdt f|r Mathematik und Informatik
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <3108ec17.0@news.uni-konstanz.de>
- Reply-To: dietmar.kuehl@uni-konstanz.de
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: 26 Jan 96 14:58:31 GMT
- X-Newsreader: TIN [version 1.2 PL2]
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMQkQfky4NqrwXLNJAQFXQAH+IjHJmmACFs2/TTnRMDPJYXt3eGFxZ0Gs
- /bLgcMQPRWubdZmQXHXfVQUxxfvqqoogdqBTcl2/+W1Lbb/VT9fHIg==
- =LfhT
- Originator: austern@isolde.mti.sgi.com
-
- Hi,
-
- The three standard classes 'stack', 'priority_queue', and 'queue' can
- be seen as classes which provide a sequence of the objects inserted
- into them depending on the order of insertation ('stack' and 'queue')
- and/or the elements themselves ('priority_queue'). In this respect it
- sometimes makes sense to define a template class or function which can
- take one of these three classes (or a similar one). However, these
- three classes have the function 'push()', 'pop()', 'empty(), and
- 'size()' in common (in addition to constructors and destructors).
- Unfortunately, this subset is normally not sufficient because there is
- no way to retrieve an "current" object. For 'stack' and
- 'priority_queue' a method 'top()' is defined to get the current object
- and for 'queue' methods 'front()' and 'back()' are defined. To conform
- to the same requirements, it would be necessary for all three classes
- to share a common method (e.g. 'top()') to retrieve the current
- element. A suitable implementation of 'queue::top()' would be to return
- 'queue::front()' (this is what a queue normally defines as the current
- object).
-
- Why is this 'queue::top() missing? Was it intentional? If so, what are
- the reasons and the suggested technic to work around the missing
- method?
- --
- dietmar.kuehl@uni-konstanz.de
- http://www.informatik.uni-konstanz.de/~kuehl
- I am a realistic optimist - that's why I appear to be slightly pessimistic
- ---
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
- is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
-